﻿@model EQueue.AdminWeb.Models.ClusterTopicQueueListViewModel
@{
    ViewBag.Title = "QueueInfoList";
}
<style>
    .header-form {
        display: inline-block;
        float: left;
    }

    .next-form {
        margin-left: 15px;
    }
</style>
<div>
    @using (Html.BeginForm("QueueInfoList", "Home", new { clusterName = ViewBag.ClusterName }, FormMethod.Post, null, new { @class = "form-inline header-form", role = "form" }))
    {
        <div class="form-group">
            <label class="sr-only" for="ClusterName"></label>
            @Html.TextBoxFor(m => m.ClusterName, new { @class = "form-control", placeholder = "ClusterName" })
        </div>
        <div class="form-group">
            <label class="sr-only" for="Topic"></label>
            @Html.TextBoxFor(m => m.Topic, new { @class = "form-control", placeholder = "Topic" })
        </div>
        <button type="submit" class="btn btn-default">查询</button>
    }
    <table class="table table-striped">
        <thead>
            <tr>
                <th width="15%" class="vertical-center">
                    BrokerName
                </th>
                <th width="10%" class="vertical-center">
                    Topic
                </th>
                <th width="10%" class="text-center vertical-center">
                    QueueId
                </th>
                <th width="10%" class="text-center vertical-center">
                    CurrentOffset
                </th>
                <th width="10%" class="text-center vertical-center">
                    MinOffset
                </th>
                <th width="10%" class="text-center vertical-center">
                    消费进度
                </th>
                <th width="10%" class="text-center vertical-center">
                    堆积数
                </th>
                <th width="5%" class="text-center vertical-center">
                    A_S
                </th>
                <th width="5%" class="text-center vertical-center">
                    A_C
                </th>
                <th width="10%" class="text-center vertical-center">
                    发送TPS
                </th>
                <th width="5%" class="vertical-center">
                    操作
                </th>
            </tr>
        </thead>
        <tbody>
            @foreach (var line in Model.TopicQueueInfoList)
            {
                foreach (var item in line.TopicQueueInfoList)
                {
                    <tr>
                        <td class="vertical-center">
                            @Html.ActionLink(@line.BrokerInfo.BrokerName, "Index", "Broker", new { clusterName = ViewBag.ClusterName, brokerName = @line.BrokerInfo.BrokerName }, null)
                        </td>
                        <td class="vertical-center">
                            @item.Topic
                        </td>
                        <td class="text-center vertical-center">
                            @item.QueueId
                        </td>
                        <td class="text-center vertical-center">
                            @item.QueueCurrentOffset
                        </td>
                        <td class="text-center vertical-center">
                            @item.QueueMinOffset
                        </td>
                        <td class="text-center vertical-center">
                            @item.QueueMinConsumedOffset
                        </td>
                        <td class="text-center vertical-center">
                            @item.QueueNotConsumeCount
                        </td>
                        <td class="text-center vertical-center">
                            @item.ProducerVisible
                        </td>
                        <td class="text-center vertical-center">
                            @item.ConsumerVisible
                        </td>
                        <td class="text-center vertical-center">
                            @item.SendThroughput
                        </td>
                        <td class="vertical-center">
                            <div class="dropdown">
                                <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">
                                    操作
                                    <span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu">
                                    <li>
                                        @Html.ActionLink("新增队列 For Cluster", "AddQueue", new { clusterName = ViewBag.ClusterName, topic = item.Topic })
                                    </li>
                                    <li>
                                        @if (item.ProducerVisible)
                                        {
                                            @Html.ActionLink("禁止发送 For Cluster", "SetQueueProducerVisible", new { clusterName = ViewBag.ClusterName, topic = item.Topic, queueId = item.QueueId, visible = !item.ProducerVisible })
                                        }
                                        else
                                        {
                                            @Html.ActionLink("允许发送 For Cluster", "SetQueueProducerVisible", new { clusterName = ViewBag.ClusterName, topic = item.Topic, queueId = item.QueueId, visible = !item.ProducerVisible })
                                        }
                                    </li>
                                    <li>
                                        @if (item.ConsumerVisible)
                                        {
                                            @Html.ActionLink("禁止消费 For Cluster", "SetQueueConsumerVisible", new { clusterName = ViewBag.ClusterName, topic = item.Topic, queueId = item.QueueId, visible = !item.ConsumerVisible })
                                        }
                                        else
                                        {
                                            @Html.ActionLink("允许消费 For Cluster", "SetQueueConsumerVisible", new { clusterName = ViewBag.ClusterName, topic = item.Topic, queueId = item.QueueId, visible = !item.ConsumerVisible })
                                        }
                                    </li>
                                    <li>@Html.ActionLink("删除队列 For Cluster", "DeleteQueue", new { clusterName = ViewBag.ClusterName, topic = item.Topic, queueId = item.QueueId })</li>
                                </ul>
                            </div>
                        </td>
                    </tr>
                }
            }
        </tbody>
    </table>
</div>

